class BG3HUD extends UTHUD;

//array holding HUDbases
var array<BG3HUDLayoutBase> layouts;

//the current active hudlayout
var BG3HUDLayoutBase currhudlayout;

//the default hudlayout
var BG3HUDLayoutBase defhudlayout;

//mouse cursor icon asset
var Texture2D cursortex;

//display size of cursor
var int cursorsizeX;
var int cursorsizeY;

//Store a reference to clip values for access in playerinput
var int ClipX;
var int ClipY;

//overwritten
function DrawHUD()
{
	PlayerOwner.DrawHUD(self);

	ClipX = Canvas.ClipX;
	ClipY = Canvas.ClipY;

	if(defhudlayout != none)
	{
		//check if current layout is valid, if not fall back to default
		if(currhudlayout == none)
		{
			currhudlayout = defhudlayout;
		}
		currhudlayout.Draw(Canvas,self);
	}
}

//add layout
simulated function AddLayout(BG3HUDLayoutBase thisbase)
{
	local int i;
	//only add it once
	for(i = 0; i < layouts.Length; i++)
	{
		if(layouts[i] == thisbase) return;
	}
	layouts.AddItem(thisbase);
}

//remove layout, do we even need this?
simulated function RemoveLayout(BG3HUDLayoutBase thisbase)
{
	local int i;
	//remove only if it exists
	for(i = 0; i < layouts.Length; i++)
	{
		if(layouts[i] == thisbase) layouts.RemoveItem(thisbase);
	}
}

//toggle bEnabled on specific layout and set it as current active layout
simulated function ToggleHUDLayout(string menuname)
{
	local int i;
	if(layouts.Length > 0)
	{
		for(i = 0; i < layouts.Length; i++)
		{
			if(layouts[i].sLayoutName == menuname)
			{
				if(layouts[i].bEnabled == false)
				{
					//we are turning it on
					currhudlayout = layouts[i];
					layouts[i].bEnabled = true;
				}
				else
				{
					//we are turning it off, set the active layout back to the default
					currhudlayout = defhudlayout;
					layouts[i].bEnabled = false;
				}
			}
		}
	}
}


defaultproperties
{
	begin object Class=BG3ClassSelectionMenu Name=testmenu
		end object
	begin object Class=BG3MainGameHUDLayout Name=gamehud
		bEnabled = true
		end object
	layouts[0] = gamehud
	layouts[1] = testmenu
	defhudlayout = gamehud

	cursortex = Texture2D'BG3TestPackage.testcursor'
	cursorsizeX = 32
	cursorsizeY = 32
		
}